package Class_04_07;

class ColaEmployee
{
    private String name;
    private int b_month;

    public double getSalary(int b_month)
    {
        return 0;
    }

    public ColaEmployee() {
    }

    public ColaEmployee(String name, int b_month) {
        this.name = name;
        this.b_month = b_month;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getB_month() {
        return b_month;
    }

    public void setB_month(int b_month) {
        this.b_month = b_month;
    }
}

//SalariedEmployee 拿固定工资的员工
class SalariedEmployee extends ColaEmployee
{
    private double monSalary;

    public SalariedEmployee() {
    }

    public SalariedEmployee(String name, int b_month, double monSalary) {
        super(name, b_month);
        this.monSalary = monSalary;
    }

    public double getSalary(int month)
    {
        if(getB_month() == month)
        {
            //该员工过生日
            return monSalary + 100;
        }
        else
        {
            return monSalary;
        }
    }
}

//HourlyEmployee 按小时拿工资的员工
class HourlyEmployee extends ColaEmployee
{
    private double hourSalary; //小时工资
    private int hours; //工作时间

    public HourlyEmployee() {
    }

    public HourlyEmployee(String name, int b_month, double hourSalary, int hours) {
        super(name, b_month);
        this.hourSalary = hourSalary;
        this.hours = hours;
    }

    //分情况讨论 1.超过160小时
    //         2.不超过160小时
    //         3.超过160小时 + 过生日
    //         4.没超过160小时 + 过生日
    public double getSalary(int month)
    {
        if(getB_month() == month)//过生日
        {
            if(hours > 160)
            {
                //超过160小时且过生日
                return hourSalary * 160 + hourSalary * (hours - 160) * 1.5 + 100;
            }
            else
            {
                //未超过160小时但过生日
                return hourSalary * hours + 100;
            }
        }
        else
        {
            if(hours > 160)
            {
                //超过160小时但不过生日
                return hourSalary * 160 + hourSalary * (hours - 160) * 1.5;
            }
            else
            {
                //不超过160小时且不过生日
                return hourSalary * hours;
            }
        }
    }
}

class SalesEmployee extends ColaEmployee
{
    private double salesmonth; //月销售额
    private double royaltyrate; //提成率

    public SalesEmployee() {
    }

    public SalesEmployee(String name, int b_month, double salesmonth, double royaltyrate) {
        super(name, b_month);
        this.salesmonth = salesmonth;
        this.royaltyrate = royaltyrate;
    }

    public double getSalary(int month)
    {
        //工资由销售额和提成率决定
        if(getB_month() == month)
        {
            //过生日
            return salesmonth * royaltyrate + 100;
        }
        else
        {
            return salesmonth * royaltyrate;
        }
    }
}

class Company
{
    public void PrintSalary(ColaEmployee employee, int month)
    {
        System.out.println(employee.getName() +"在第" + month + "月的工资为：" + employee.getSalary(month));
    }
}
public class Main2 {
    public static void main(String[] args) {
        ColaEmployee[] Employees = {
                new SalariedEmployee("Jack",6,7000),
                new HourlyEmployee("Mary",4,20,170),
                new SalesEmployee("Black",12,10000,1)};
        for (int i = 0; i < Employees.length; i++) {
            new Company().PrintSalary(Employees[i],12);
        }
    }
}
